# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from tinymce.models import HTMLField

# 商品类型
class TypeInfo(models.Model):
    tname = models.CharField(max_length = 20)
    isDelete = models.BooleanField(default = False)
    def __str__(self):
        return self.tname.encode('utf-8')

# 商品
class GoodInfo(models.Model):
    gname = models.CharField(max_length = 20)
    gpic = models.ImageField(upload_to = 'goods_pic')
    gprise = models.DecimalField(max_digits = 6, decimal_places = 2)
    gunit = models.CharField(max_length = 10, default = '500g')
    gclicks = models.IntegerField(default = 0)
    gtitle = models.CharField(max_length = 100)
    gcontent = HTMLField()
    gtype = models.ForeignKey(TypeInfo)
    ginventory = models.IntegerField(default = 0)
    isDelete = models.BooleanField(default = False)
    def __str__(self):
        return self.gname.encode('utf-8')